#! /bin/bash
#网络名称
networkname="eureka-overlay"
#编排文件
docker_compost_yml="eureka.yml"
#创建的image_name
build_image_Name="java:euraka"
#工作目录
Work_dir="/honme"
#image——tag
Docker_image_tag="192.168.19.132:5000/java:euraka"
#服务列表
Service_names="java_eureka1 java_eureka2 java_eureka3"

cd ${Work_dir}
echo cd ${Work_dir}

docker build -t ${build_image_Name} .

docker tag ${build_image_Name}  ${Docker_image_tag}
docker push ${Docker_image_tag}

docker service ls

for service in $Service_names;
do
    docker service rm  $service

done

docker network rm ${networkname}
docker network create -d overlay ${networkname}
docker network ls
docker stack deploy  -c ${docker_compost_yml} java

for service in $Service_names;
do
    docker service ps  $service
    echo $service
done

docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")
rm -rf /home/Sping-Cloud-eureka-Server-0.0.1-SNAPSHOT.jar
rm -rf /home/Dockerfile
rm -rf /home/eureka.yml
docker service ls
docker node ls